{{! 反序列化方法：简化的默认值处理 }}
deserialize(decoder: Decoder, plain: ESObject): {{class.className}}{{#if class.generics.isGeneric}}<{{genericParametersString class.generics.parameters}}>{{/if}} {
  const keys = this.serialDescriptor.elementDecodingNames;

  {{#if (isClassType class)}}
    {{! 解码构造函数属性（直接反序列化）}}
    const result = new {{class.className}}{{#if class.generics.isGeneric}}<{{genericParametersString class.generics.parameters}}>{{/if}}(
    {{#each (getCtorProperties class.constructorParams properties)}}
      {{#unless analysis.decorators.isTransient}}
        {{#if analysis.decorators.isPlainValue}}plain[keys[{{getPropertyIndex this ../properties}}]]{{else}}{{#if (and (eqPrimitiveType analysis.type.kind) (not (hasDecoratorWith analysis.decorators)))}}decoder.{{serializer.decodeMethod}}(plain[keys[{{getPropertyIndex this ../properties}}]]){{else}}this.{{analysis.name}}Serializer.deserialize(decoder, plain[keys[{{getPropertyIndex this ../properties}}]]){{/if}}{{#if serializer.needsTypeAssertion}} as {{analysis.type.sourceText}}{{/if}}{{/if}}{{#unless @last}},{{/unless}}
      {{/unless}}
    {{/each}});
  {{else}}
    const result: ESObject = {};
  {{/if}}


  {{! 可选属性赋值（构造函数外的属性）}}
  {{#each (postConstructorAssignments class.constructorParams properties)}}
    {{#unless analysis.decorators.isTransient}}
      const {{analysis.name}}PlainValue: ESObject = plain[keys[{{getPropertyIndex this ../properties}}]];
      {{#if analysis.defaultValue}}
      {{! 有默认值的属性 }}
      {{#if (eq analysis.visibility "private")}}
      ObjectUtils.setProp(result, '{{analysis.name}}', {{analysis.name}}PlainValue === undefined ? {{analysis.defaultValue}} :
        {{#if analysis.decorators.isPlainValue}}plain[keys[{{getPropertyIndex this ../properties}}]]{{else}}{{#if (and (eqPrimitiveType analysis.type.kind) (not (hasDecoratorWith analysis.decorators)))}}decoder.{{serializer.decodeMethod}}(plain[keys[{{getPropertyIndex this ../properties}}]]){{else}}this.{{analysis.name}}Serializer.deserialize(decoder, plain[keys[{{getPropertyIndex this ../properties}}]]){{/if}}{{#if serializer.needsTypeAssertion}} as {{analysis.type.sourceText}}{{/if}}{{/if}});
      {{else}}
      result.{{analysis.name}} = {{analysis.name}}PlainValue === undefined ? {{analysis.defaultValue}} :
        {{#if analysis.decorators.isPlainValue}}plain[keys[{{getPropertyIndex this ../properties}}]]{{else}}{{#if (and (eqPrimitiveType analysis.type.kind) (not (hasDecoratorWith analysis.decorators)))}}decoder.{{serializer.decodeMethod}}(plain[keys[{{getPropertyIndex this ../properties}}]]){{else}}this.{{analysis.name}}Serializer.deserialize(decoder, plain[keys[{{getPropertyIndex this ../properties}}]]){{/if}}{{#if serializer.needsTypeAssertion}} as {{analysis.type.sourceText}}{{/if}}{{/if}};
      {{/if}}
      {{else}}
      {{! 无默认值的属性 }}
      {{#if (eq analysis.visibility "private")}}
      ObjectUtils.setProp(result, '{{analysis.name}}', {{analysis.name}}PlainValue === undefined ? undefined :
        {{#if analysis.decorators.isPlainValue}}plain[keys[{{getPropertyIndex this ../properties}}]]{{else}}{{#if (and (eqPrimitiveType analysis.type.kind) (not (hasDecoratorWith analysis.decorators)))}}decoder.{{serializer.decodeMethod}}(plain[keys[{{getPropertyIndex this ../properties}}]]){{else}}this.{{analysis.name}}Serializer.deserialize(decoder, plain[keys[{{getPropertyIndex this ../properties}}]]){{/if}}{{#if serializer.needsTypeAssertion}} as {{analysis.type.sourceText}}{{/if}}{{/if}});
      {{else}}
      result.{{analysis.name}} = {{analysis.name}}PlainValue === undefined ? undefined :
        {{#if analysis.decorators.isPlainValue}}plain[keys[{{getPropertyIndex this ../properties}}]]{{else}}{{#if (and (eqPrimitiveType analysis.type.kind) (not (hasDecoratorWith analysis.decorators)))}}decoder.{{serializer.decodeMethod}}(plain[keys[{{getPropertyIndex this ../properties}}]]){{else}}this.{{analysis.name}}Serializer.deserialize(decoder, plain[keys[{{getPropertyIndex this ../properties}}]]){{/if}}{{#if serializer.needsTypeAssertion}} as {{analysis.type.sourceText}}{{/if}}{{/if}};
      {{/if}}
      {{/if}}
    {{/unless}}
  {{/each}}

  return result as {{class.className}}{{#if class.generics.isGeneric}}<{{genericParametersString class.generics.parameters}}>{{/if}};
}